home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3042 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  72 lines

  1. Newsgroups: comp.lang.c
  2. Path: ritz.mordor.com!news
  3. From: benjamin@ritz.mordor.com (Joseph Thomas)
  4. Subject: Help: Need to simplify a Makefile for a large project
  5. X-Newsreader: Gnus v5.1
  6. X-Nntp-Posting-User: benjamin
  7. Sender: benjamin@ritz.mordor.com
  8. Organization: None
  9. Message-ID: <5rg2d4ti39.fsf@ritz.mordor.com>
  10. X-Nntp-Posting-Host: ritz.mordor.com
  11. Date: Thu, 25 Jan 1996 15:22:18 GMT
  12.  
  13. I'm trying to devise an efficient method of constructing a Makefile
  14. for a big project that needs to function like this:
  15.  
  16. (oversimplified example):
  17.  
  18.  
  19. APP_1_DEFINE = -D APP_1
  20. APP_2_DEFINE = -D APP_2
  21.  
  22. all: project1 project2
  23.  
  24. project1: a.c b.c
  25.     cc $(APP_1_DEFINE) project.c a.o b.o -o project1
  26.  
  27. a: a.c
  28.     cc -c $(APP_1_DEFINE) a.c -o a.o
  29.  
  30. b: b.c b.h
  31.     cc -c $(APP_1_DEFINE) b.c -o b.o
  32.  
  33.  
  34. project2: a.c b.c
  35.     cc $(APP_2_DEFINE) project.c a.o b.o -o project2
  36.  
  37. a: a.c
  38.     cc -c $(APP_2_DEFINE) a.c -o a.o
  39.  
  40. b: b.c b.h
  41.     cc -c $(APP_2_DEFINE) b.c -o b.o
  42.  
  43.  
  44.  
  45. (This example itself is probably incorrect because I'm making a and b
  46. a target twice, but I'm hoping it will get my idea across anyway).
  47.  
  48. In other words, every time a dependent file changes, I need to make
  49. two 'versions' of the whole project.  All the differences between
  50. project1 and project2 come about strictly because of the -D APP_#
  51. being passed to the compiler.
  52.  
  53. Isn't there some way to do this without having to duplicate one
  54. version's definition?  Is it possible to have the
  55.  
  56. project1: a.c b.c
  57.  
  58. line look something like
  59.  
  60. project$(VERSION): a.c b.c
  61.  
  62. , where, in this example, VERSION would be 1, then 2, and have make
  63. "loop" through the definition of project for the two different
  64. versions?  Even better, could the -D APP_#_DEFINE also be derived from
  65. VERSION?  (for each iteration, APP_DEFINE's value could change to
  66. APP_$(VERSION) ) - thus requiring me to add only one extra value of
  67. VERSION to the Makefile everytime I want to introduce a new version of
  68. the project?
  69.  
  70. Help would be greatly appreciated
  71.     -Joe
  72.